package thread;

public class demo12 {
    public static void main(String[] args) throws InterruptedException {
        //获取到main的引用
        Thread main = Thread.currentThread();

        Thread t = new Thread(()->{
            //让t线程阻塞等待main线程
            try {
                System.out.println("t 线程等待之前");
                main.join();
                System.out.println("t 线程等待之前");
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        });
        t.start();

        //让main线程执行一定的逻辑
        for (int i = 0; i < 5; i++) {
            System.out.println("hello main");
            Thread.sleep(1000);
        }
    }
}
